package cn.ssdcc.dkserver.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.*;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.JstlView;

@Configuration
public class WebMvcConfig extends WebMvcConfigurationSupport {

    /**
     * 跨域
     **/
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedHeaders("*")
                .allowedOriginPatterns("*")
                .allowedMethods("POST","GET","PUT","OPTIONS","DELETE")
                .allowCredentials(true);
    }
    /**
     * 静态资源处理
     **/
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/music/**").addResourceLocations("file:" + "./data/music/");
        registry.addResourceHandler("/im/**").addResourceLocations("file:" + "./data/im/");
        registry.addResourceHandler("/musicimg/**").addResourceLocations("file:" + "./data/musicimg/");
        registry.addResourceHandler("/user/**").addResourceLocations("file:" + "./data/user/");
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
        registry.addResourceHandler("/dk/**").addResourceLocations("classpath:/dk/");
        registry.addResourceHandler("/favicon.ico").addResourceLocations("classpath:/static/favicon.ico");
    }

}
